//package com.admins.filters;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
///**
// * @author mis_wu
// * @date 2021/12/19 11:34
// */
//@WebFilter(filterName = "OriginFilter")
//public class OriginFilter implements Filter {
//    public void destroy() {
//    }
//
//    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws 			     ServletException, IOException {
////        res.setCharacterEncoding("utf-8");
////        res.setContentType("text/json;charset=utf-8");
////        req.setCharacterEncoding("utf-8");
//        /** 设置响应头允许ajax跨域访问 **/
//        HttpServletRequest request=(HttpServletRequest) req;
//        HttpServletResponse response=(HttpServletResponse)resp;
//        request.setCharacterEncoding("utf-8");
//        response.setContentType("text/json;charset=utf-8");
//
//        String origin="*";
//        if(request.getHeader("Origin")!=null){
//            origin=request.getHeader("Origin");
//        }
//        response.setHeader("Access-Control-Allow-Origin","*");
//        response.setHeader("Access-Control-Allow-Origin", origin);
//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
//        response.setHeader("Access-Control-Max-Age", "3600");
//        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type, token");
//        response.setHeader("Access-Control-Allow-Credentials", "true");
//        chain.doFilter(request, response);
//    }
//
//    public void init(FilterConfig config) throws ServletException {
//
//    }
//}
